<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddUsersColumnsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->dropColumn('name');
            $table->string('username', 50)->unique()->comment('用户名');
            $table->string('email', 100)->comment('邮箱')->change();
            $table->string('password')->comment('密码')->change();
            $table->string('avatar')->nullable()->comment('头像');
            $table->string('login_ip', 20)->default('127.0.0.1')->comment('登录ip');
            $table->integer('login_count')->default('0')->comment('登录次数');
            $table->string('nick_name', 20)->nullable()->comment('昵称');
            $table->string('chinese_name', 20)->nullable()->comment('真实姓名');
            $table->boolean('sex')->default('0')->comment('性别，1男，0女');

            $table->string('qq', 20)->nullable()->comment('qq');
            $table->string('phone', 20)->nullable()->comment('电话');

            $table->boolean('status')->default('0')->index()->comment('状态1启用，0禁用');
            $table->integer('department_id')->default('0')->index()->comment('所属部门');
            $table->boolean('public')->default('0')->index()->comment('可否查看本人资料0不可以，1可以');
            $table->boolean('upload_private')->default('0')->index()->comment('上传文件是否私有，0否，1私有');

            $table->softDeletes();

        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('users', function (Blueprint $table) {
            //
        });
    }
}
